package com.lsa.letcode.the92.reverseLinkedListII;

import org.junit.Test;

import com.lsa.letcode.common.LetCodeTestBase;
import com.lsa.letcode.common.ListNode;

public class ReverseLinkedListIITest extends LetCodeTestBase{
	@Test
	public void test() throws Exception {
		test(asList(1, 2), 1, 2, asList(2, 1));
		test(asList(1), 1, 1, asList(1));
		test(asList(1, 2, 3, 4, 5), 2, 4, asList(1, 4, 3, 2, 5));
		test(asList(1, 2, 3, 4, 5), 2, 5, asList(1, 5, 4, 3, 2));
		test(asList(1, 2, 3, 4, 5), 1, 5, asList(5, 4, 3, 2, 1));
		test(asList(1, 2, 3, 4, 5), 1, 4, asList(4, 3, 2, 1, 5));
		test(asList(1, 2, 3, 4, 5, 6), 2, 5, asList(1, 5, 4, 3, 2, 6));
	}

	private void test(ListNode l, int idxStart, int idxStop, ListNode expected) {
		Solution s = new Solution();
		ListNode res = s.reverseBetween(l, idxStart, idxStop);
		assertEqual(expected, res);
	}
}
